package msc.ai.crypto.jade.security;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.security.Key;
import java.security.NoSuchAlgorithmException;

/**
 * Created by IntelliJ IDEA.
 * User: prageeth
 * Date: 4/27/12
 * Time: 4:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class KDC
{
    private static Key key;

//    public static Key getKey()
//    {
//        if (key == null)
//        {
//            KeyGenerator keyGenerator = null;
//            try
//            {
//                keyGenerator = KeyGenerator.getInstance("DES");
//            } catch (NoSuchAlgorithmException e)
//            {
//                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
//            }
//            key = keyGenerator.generateKey();
//        }
//        return key;
//    }

    public static Key getKey()
    {
        if (key == null)
        {
            KeyGenerator keyGenerator = null;
            try
            {
                keyGenerator = KeyGenerator.getInstance("AES");
            } catch (NoSuchAlgorithmException e)
            {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
            key = keyGenerator.generateKey();
        }
        return key;
    }
}
